<template>
  <div>
    <TypeNav />
    <List />
    <Recommend />
    <Rank />
    <Like />
    <Floor v-for="(floor, index) in floorList" :key="index" :floor="floor" />

    <Brand />
  </div>
</template>

<script>
//导入mapstate方法  拿到vuex中的数据
import List from "@/pages/Home/List/List.vue";
import Recommend from "@/pages/Home/Recommend";
import Rank from "@/pages/Home/Rank";
import Like from "@/pages/Home/Like";
import Floor from "@/pages/Home/Floor";
import Brand from "@/pages/Home/Brand";
import { mapState } from "vuex";

export default {
  components: {
    List,
    Recommend,
    Rank,
    Like,
    Floor,
    Brand,
  },
  //floor组件挂载完开始请求数据，为什么在home页面请求呢？ 因为floor组件被复用了两次
  //在这之后  v-for  传递给floor
  mounted() {
    this.$store.dispatch("getFloorList");
    //home 页 一挂载完 凭借token 请求一下用户的信息
    this.$store.dispatch("getUserInfo");
  },
  computed: {
    ...mapState({ floorList: (state) => state.home.floorList }),
  },
  beforeMount() {},
};
</script>

<style>
</style>